<!DOCTYPE html>
<html>
<head>
<title>商品兑换</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<#include "../../../../include/resources.html">
<script type="text/javascript">
    var dataGrid;
    var winWidth = 750;
    var winHeight = 400;
	
    var verifyTitle = "商品兑换审核";
    var verifyUrl =  "/modules/user/score/convert/verify.html";
    var verifyWinParmeters = "'{0}','"+verifyTitle+"',920,650,'"+verifyUrl+"'";
    
	var deliveryTitle = "商品发货";
    var deliveryUrl =  "/modules/user/score/convert/delivery.html";
    var deliveryWinParmeters = "'{0}','"+deliveryTitle+"',920,650,'"+deliveryUrl+"'";
    
    $(function() {
        dataGrid = $('#dataGrid').datagrid({
            url : 'list.html',
            fit : true,
            fitColumns : true,
            border : false,
            pagination : true,
            idField : 'id',
            pageSize : pageSize,
            pageNums :1,
            pageList : pageList,
            sortName : 'id',
            sortOrder : 'asc',
            checkOnSelect : false,
            selectOnCheck : false,
            nowrap : false,
			singleSelect:true,
            frozenColumns:[[
                
            ]],
            columns : [ [
				{ field: 'id', title: '编号', width: 50, sortable:false },
				{ field: 'userName', title: '用户名', width: 100, sortable:false },
				{ field: 'name', title: '商品名称', width: 150, sortable:false },
				{ field: 'isVirtual', title: '虚拟商品', width: 80, sortable:false,
                	formatter: function(value,row,index){
                		if(value == 0){
                			return "否";
                		} else if(value == 1){
                			return "是";
                		}
                  	} 
             	},
                { field: 'convertNum', title: '兑换数量', width: 80, sortable:false },
                { field: 'score', title: '单个积分', width: 80, sortable:false},
                { field: 'receiveMobile', title: '收货人手机', width: 100, sortable:false },
                { field: 'courierNum', title: '快递单号', width: 120, sortable:false },
                { field: 'addTime', title: '兑换时间', width: 150, sortable:false,
                	formatter: function(value,row,index){
                		return getLocalTime(value, 4);
                	}
                },
                { field: 'status', title: '状态', width: 80, sortable:false,
	                formatter: function(value,row,index){
	                	if(value == 0){
	                		return "待审核";
	                	} else if(value == 1){
	                		return "审核通过";
	                	} else if(value == -1){
	                		return "审核不通过";
	                	} else if(value == 2){
	                		return "已发货";
	                	} else if(value == 3){
	                		return "已收货";
	                	}
                	} 
                },
                
                { field : 'showInfo',
                    title : '其他信息',
                    width : 75,
                    align : 'center',
                    fixed : true,
                    formatter : function(value, row, index) {
    					var content = '<a href="javascript:void(0);" class="j-showInfo">查看<i class="iconfont">&#xe639;</i></a>'
    						+ '<div class="showInfoSingleDiv">'
    						+ '<div class="showInfo">'
    						+ '<em></em><h2>积分兑换信息</h2>'
    						+ '<ul>'
    						+ '<li>'
							+ '<span>备注：</span>'
    						+ row.remark
    						+ '</li>';
    					if(row.status != 0){
    						content += '<li>'
                       		+ '<span>审核时间：</span>'
       						+ getLocalTime(row.verifyTime, 4)
       						+ '</li>'
       						+ '<li>'
                    		+ '<span>审核备注：</span>'
    						+ row.verifyRemark
    						+ '</li>';
    					}
    					if(row.status == 2){
    						content += '<li>'
                       		+ '<span>发货时间：</span>'
       						+ getLocalTime(row.deliverTime, 4)
       						+ '</li>';
    					}
    					if(row.status == 2 || row.status == 3){
    						content += '<li>'
                    		+ '<span>收货人：</span>'
    						+ row.receiver
    						+ '</li>'
    						+ '<li>'
                    		+ '<span>电话：</span>'
    						+ row.receivePhone
    						+ '</li>'
    						+ '<li>'
                    		+ '<span>快递名称：</span>'
    						+ row.courierName
    						+ '</li>'
    						+ '<li>'
                    		+ '<span>收货地址：</span>'
    						+ row.receiveAddress
    						+ '</li>';
    					}
    					content += '</ul></div></div>';
    					return content;
    				}
    			},
    			
                { field : 'action',
	                title : '操作',
	                width :80,
	                fixed:true,
	                formatter : function(value, row, index) {
	                	var status = row.status;
	                	var type = row.type;
	                    var str = '';
	                    if (status == 0) {
	                    	str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.editFun('+row.id+',verifyTitle,winWidth,winHeight,verifyUrl);" title="审核商品兑换信息">审核</a>';
	                	} else if(status == 1){
	                		str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.editFun('+row.id+',deliveryTitle,winWidth,winHeight,deliveryUrl);" title="发货">发货</a>';
	                	}
	                    return str;
	                }
	            } 
            ] ],
            toolbar : '#toolbar',
            onLoadSuccess : function() {
                $('#searchForm table').show();
                parent.$.messager.progress('close');
            },
            onRowContextMenu : function(e, rowIndex, rowData) {
                e.preventDefault();
                $(this).datagrid('unselectAll').datagrid('uncheckAll');
                $(this).datagrid('selectRow', rowIndex);
                $('#menu').menu('show', {
                    left : e.pageX,
                    top : e.pageY
                });
            }
        });
    });
</script>
</head>
<body style="padding:0 20px;" >
	<div class="easyui-layout" data-options="fit : true,border : false">
        <div data-options="region:'north',border:false,collapsible:false" id="searchBox">
        	<div class="sLeft">
	            <form id="searchForm">
	            	<input type="text"  name="searchName" class="sInput" placeholder="输入用户名/商品名进行搜索" onkeydown="if(event.keyCode == 13){ $.fn.dataGridOptions.searchFun('#searchForm');return false;}"/><a href="javascript:;" title="查询" class="sBtn" onclick="$.fn.dataGridOptions.searchFun('#searchForm');">查询</a><a href="javascript:;" class="advBtn" title="条件查询">条件查询 <i class="iconfont">&#xe638;</i></a>
	            	<a href="javascript:void(0);" class="reloadIcon" onclick="dataGrid.datagrid('reload');" title="刷新" ><i class="iconfont">&#xe603;</i></a>
	            </form>
            </div>
            <form id="showAdw">
		        <ul class="showAdw" style="display:none;">
		        	<a href="javascript:void(0);"><i class="iconfont closeWin">&#xe628;</i></a>
		        	<li><span>商品名</span><input type="text" name="name"  autocomplete="off"/></li>
		        	<li><span>用户名</span><input type="text" name="userName" id="userName" autocomplete="off"/></li>
		        	<li><span>收货人手机</span><input type="text" name="receiveMobile" id="receiveMobile" autocomplete="off"/></li>
					
					<li><span>状态</span><select name="status" id="status">
						<option value="99">全部</option>
						<option value="0">待审核</option>
						<option value="1">审核通过</option>
						<option value="-1">审核未通过</option>
						<option value="2">已发货</option>
						<option value="3">已收货</option>
					</select></li>
		        	<li><span>兑换时间</span><input type="text" name="startTime" id="startTime" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'endTime\')}',readOnly:true})" class="searchTime"/>&nbsp;-&nbsp;<input type="text" name="endTime" id="endTime" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')}',readOnly:true})" class="searchTime"/></li>
		       		<li><span></span><a href="javascript:void(0);" class="searchBtn sureBtn" onclick="$.fn.dataGridOptions.searchFun('#showAdw');">确定</a><a href="javascript:void(0);" class="searchBtn" onclick="$.fn.dataGridOptions.cleanFun('#searchForm');">重置</a></li>
		        </ul>
	        </form>
        </div>
        <div data-options="region:'center'" style="margin-top:30px;padding-bottom:30px;">
            <table id="dataGrid"></table>
        </div>
    </div>
</body>
</html>
<script src="${theme_dir}/js/search.js"></script>